class Ob {
  event = {}
  on(eventName, fn) {
    this.event[eventName] = this.event[eventName] || []
    this.event[eventName].push(fn)
  }
  emit(eventName) {
    if (this.event[eventName]) {
      this.event[eventName].forEach(item => {
        item()
      });
    }
  }
  off(eventName, fn) {
    if (this.event[eventName]) {
      this.event[eventName] = fn ? this.event[eventName].filter(item => item != fn) : []
    }
  }
}

const fn1 = () => { console.log(111); }
let ts = new Ob()
console.log(ts.event);
ts.on('cscs', fn1)
ts.on('cscs', () => { console.log(222); })
ts.off('cscs', fn1)
console.log(ts.event);
ts.emit('cscs')